import axios from './axios';

/**
 * 新增文章
 * @param {*} data 
 */
export const add_article = (data) => {
   return axios.post('article/add', data)
}

/**
 * 查询所有的文章
 */
export const get_articles = () => {
   return axios.get('article/all');
}

/**
* 查询单篇文章
* @param {*} data 
*/
export const get_one = (id) => {
   return axios.get(`article/one/${id}`);
}

/**
 * 点赞
 * @param {*} id 
 */
export const addAgree = (id, count, artUserId) => {
   return axios.post('/article/addAgree', { data: { id, count, artUserId } })
}

/**
 * 获取用户文章
 * @param {*}  
 */
export const getUserArticles = (id) => {
   return axios.post('/article/getUserArticles', { data: { id } })
}

/**
 * 获取点赞的文章
 * @param {*}  
 */
export const getUserAgreeArticles = (id) => {
   return axios.post('/article/getUserAgreeArticles', { data: { id } })
}


/**
 * 评论
 * @param {*} data 
 */
export const comment = (data) => {
   return axios.post('/article/comment', { data })
}

/**
 * 获取评论
 */

export const getComment = (id) => {
   return axios.get('/article/getComments', { params: { id } })
}


/**
 * 删除该评论
 * @param {*} data 
 */
export const removeComment = (data) => {
   return axios.post('/article/removeComment', { data })
}


/**
 * 获得用户的所有文章
 * @param {*} params 
 */
export const getUserArticle = (params) => {
   return axios.get('/article/getUserArticle', { params })
}

